package com.efast.dmom.mgmt.controller.les;

import com.efast.cafe.framework.bean.ResultBean;
import com.efast.dmom.mgmt.entity.les.TwInvPacktranDetail;
import com.efast.dmom.mgmt.service.les.TwInvPacktranDetailService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 5.3.3 补货管理（Web端）
 * 
 * @author Administrator
 *
 */
@Controller
@RequestMapping(value = "/twInvPacktranDetail")
@Api(description = "物流执行管理-->补货-->补货管理detail")
public class TwInvPacktranDetailController {

	private final TwInvPacktranDetailService twInvPacktranDetailService;

	@Autowired
	public TwInvPacktranDetailController(TwInvPacktranDetailService twInvPacktranDetailService) {
		this.twInvPacktranDetailService = twInvPacktranDetailService;
	}


	@ApiOperation(value = "【补货完成】", notes = "请求参数：")
	@RequestMapping(value = "/replenishmentFinish", method = RequestMethod.POST)
	public @ResponseBody ResultBean replenishmentFinish(@RequestBody TwInvPacktranDetail twInvPacktranDetail) {
		ResultBean result = new ResultBean(true, "'");
		if (twInvPacktranDetail.getAcallFlag().equals("1")) {
			twInvPacktranDetailService.replenishmentFinish(twInvPacktranDetail);
		}else {
			twInvPacktranDetailService.replenishmentFinishNotAllot(twInvPacktranDetail);
		}
		return result;
	}
	
	@ApiOperation(value = "【按行关闭】", notes = "请求参数：")
	@RequestMapping(value = "/close", method = RequestMethod.POST)
	public @ResponseBody ResultBean close(@RequestBody TwInvPacktranDetail twInvPacktranDetail) {
		ResultBean result = new ResultBean(true, "'");
		// 0:新任务，1：任务确认,2:部分分配，3：分配完成，4：分配失败，5：部分拣货，6拣货完成，7任务完成，8：关闭，9：补货失败
		twInvPacktranDetail.setTaskStatue("8");
		twInvPacktranDetailService.updateNonEmptyTwInvPacktranDetailById(twInvPacktranDetail);
		return result;
	}
	
	@ApiOperation(value = "【按行分配】", notes = "请求参数：")
	@RequestMapping(value = "/distribution", method = RequestMethod.POST)
	public @ResponseBody ResultBean distribution(@RequestBody TwInvPacktranDetail twInvPacktranDetail) {
		ResultBean result = new ResultBean(true, "'");
		twInvPacktranDetailService.distribution(twInvPacktranDetail);
		return result;
	}
	
	@ApiOperation(value = "【产生拣货任务】", notes = "请求参数：")
	@RequestMapping(value = "/picking", method = RequestMethod.POST)
	public @ResponseBody ResultBean picking(@RequestBody TwInvPacktranDetail twInvPacktranDetail) {
		ResultBean result = new ResultBean(true, "'");
		return result;
	}
}
